package List;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class Exercise {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        list.add("ddd");
        list.add("eee");
        list.add("fff");
        list.add("ggg");
        list.add("hhh");
        list.add("iii");
        list.add("jjj");
        list.add("kkk");
        System.out.println(list);
        System.out.println("在第二个位置插入元素...");
        list.add(1,"王艺锡");
        System.out.println(list);
        System.out.println("获取第5个元素..");
        System.out.println(list.get(4));
        System.out.println(list);
        System.out.println("删除第6个元素");
        list.remove(5);
        System.out.println(list);
        System.out.println("修改第7个元素");
        list.set(6,"123");
        System.out.println(list);

        System.out.println("===========迭代器遍历============");
        Iterator iterator = list.iterator();
        while (iterator.hasNext()){
            Object obj = iterator.next();
            System.out.println(obj);
        }

        System.out.println("=======增强for遍历=======");
        for (Object o :list) {
            System.out.println(o);
        }

        System.out.println("======普通循环遍历=======");
        for (int i = 0;i<list.size();i++){
            System.out.println(list.get(i));
        }


    }
}
